
package interface_grafica;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

import org.omg.CORBA.BooleanSeqHelper;

import listeners.ListenersTelaCarteiraSocios;
import listeners.ListenersTelaConsultaSocio;
import listeners.ListenersTelaConsultaDoacao;

public class TelaConsultaDoacao extends javax.swing.JPanel {
    
    private static TelaConsultaDoacao instance;

    public static TelaConsultaDoacao getInstance() {
        if (instance == null) {
            instance = new TelaConsultaDoacao();
        }
        return instance;
    }     
        
    public TelaConsultaDoacao() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaDoacoes = new javax.swing.JTable();
        jLabel6 = new javax.swing.JLabel();
        tipoBuscaDoacao = new javax.swing.JComboBox();
        campoBuscaDoacao = new javax.swing.JTextField();
        botaoBuscaDoacao = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(1063, 557));

        tabelaDoacoes.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tabelaDoacoes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null}
            },
            new String [] {
                "ID", "Nome", "Data da doacao", "Quantidade"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaDoacoes.getTableHeader().setReorderingAllowed(false);
        tabelaDoacoes.getSelectionModel().addListSelectionListener(new ListenersTelaConsultaDoacao());   
              
        jScrollPane1.setViewportView(tabelaDoacoes);
        tabelaDoacoes.getColumnModel().getColumn(3).setResizable(false);

        jLabel6.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel6.setText("Filtrar por");

        tipoBuscaDoacao.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        tipoBuscaDoacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID", "Data de doacao" }));

        campoBuscaDoacao.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N

        botaoBuscaDoacao.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        botaoBuscaDoacao.setText("Pesquisar");
        botaoBuscaDoacao.addActionListener(new ListenersTelaConsultaDoacao());

        btCancelar.setText("Cancelar");
        btCancelar.addActionListener(new ListenersTelaConsultaDoacao());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Consulta de Doacoes");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(92, 92, 92)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tipoBuscaDoacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(campoBuscaDoacao)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(botaoBuscaDoacao))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(93, 93, 93)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 857, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(113, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(btCancelar)
                        .addGap(87, 87, 87))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(413, 413, 413))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tipoBuscaDoacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(campoBuscaDoacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botaoBuscaDoacao))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(28, 28, 28)
                .addComponent(btCancelar)
                .addGap(45, 45, 45))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoBuscaDoacao;
    private javax.swing.JButton btCancelar;
    private javax.swing.JTextField campoBuscaDoacao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tabelaDoacoes;
    private javax.swing.JComboBox tipoBuscaDoacao;
    // End of variables declaration//GEN-END:variables

    public JButton getBotaoBuscaDoacao() {
        return botaoBuscaDoacao;
    }

    public JButton getBtCancelar() {
        return btCancelar;
    }

    public String getCampoBuscaDoacao() {
        return campoBuscaDoacao.getText();
    }

    public JTable getTabelaDoacoes() {
        return tabelaDoacoes;
    }

    public JComboBox getTipoBuscaDoacao() {
        return tipoBuscaDoacao;
    }
    
    public DefaultTableModel getDtm() {

  		DefaultTableModel dtm = (DefaultTableModel) tabelaDoacoes.getModel();

  		return dtm;
  	}
      
     public void limpaDtm(){		
  		getDtm().setNumRows(0);
  	}



}
